package com.mrx.commons.redis.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;

/**
 * @author : Mr.X
 * @since : 2023-03-11 09:05
 **/
@Component
@ConditionalOnBean(RedisMessageListenerContainer.class)
public class FakeKeyExpirationEventMessageListener extends KeyExpirationEventMessageListener {

    private static final Logger logger = LoggerFactory.getLogger(FakeKeyExpirationEventMessageListener.class);

    /**
     * Creates new {@link MessageListener} for {@code __keyevent@*__:expired} messages.
     *
     * @param listenerContainer must not be {@literal null}.
     */
    @Autowired
    public FakeKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
        logger.debug("构造 FakeKeyExpirationEventMessageListener");
    }

    @Override
    public void afterPropertiesSet() {
        // 去除对 init 方法的调用, 不然需要真的 redis 连接
    }

}
